package com.example.permissionservice.controller;

import com.example.common.dto.ApiResponse;
import com.example.permissionservice.service.PermissionService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/permission")
@RequiredArgsConstructor
public class PermissionController {

    private final PermissionService permissionService;

    @PostMapping("/bind-default-role/{userId}")
    public ApiResponse<Void> bindDefaultRole(@PathVariable Long userId) {
        return permissionService.bindDefaultRole(userId);
    }

    @GetMapping("/user-role/{userId}")
    public ApiResponse<String> getUserRoleCode(@PathVariable Long userId) {
        return permissionService.getUserRoleCode(userId);
    }

    @PostMapping("/upgrade-to-admin/{userId}")
    public ApiResponse<Void> upgradeToAdmin(@PathVariable Long userId) {
        return permissionService.upgradeToAdmin(userId);
    }

    @PostMapping("/downgrade-to-user/{userId}")
    public ApiResponse<Void> downgradeToUser(@PathVariable Long userId) {
        return permissionService.downgradeToUser(userId);
    }
}